package org.showData;

import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import org.openModule.StageWindowsModulePane;
import org.window.App;
import org.window.PaneController;

/**
 * 显示数据窗口
 */
public class StageWindowShow {
    public static Stage stage = new Stage();
    public static void init(){
//        stage.initOwner(App.stage);
//        stage.initModality(Modality.WINDOW_MODAL);
        stage.setAlwaysOnTop(true);
        stage.setResizable(false);
        stage.setTitle("实时显示数据");
        stage.setWidth(300);
        stage.setHeight(260);
        stage.hide();
        stage.setScene(new Scene(StageWindowShowAndPane.pane));
        stage.getScene().getStylesheets().addAll(PaneController.class.getClassLoader().getResource("style.css").toExternalForm());
        StageWindowShowAndPane.init();
        stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
            @Override
            public void handle(WindowEvent event) {
                stage.hide();
            }
        });
        stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
            @Override
            public void handle(WindowEvent event) {
                StageWindowShowAndPaneAndVBoxAndHBoxAndLableTextFind.textField.setText("");
            }
        });
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true){
                    StageWindowShow.stage.setX(PaneController.stage.getX()-290);
                    StageWindowShow.stage.setY(PaneController.stage.getY()+440);
                }
            }
        }).start();
    }
}
